import tkinter
from tkinter import *
from tkinter import messagebox

i = 0
say1 = ["不要抱怨", "你知道我的缺点是什么吗", "我觉得你这个人不适合谈恋爱", "你知道你和星星有什么区别吗", "我好爱你噢"]
say = ["抱我", "缺点你", "适合结婚", "星星在天上,你在我心里", "走,我们领证去"]


# 当关闭窗口时触发
def closeWindon():
    messagebox.showinfo(title="警告", message="关不掉噢,气不气气不气")
    return


# 同意之后关闭弹窗
def closeallwindon():
    global i
    i += 1
    if i > 4:
        windon.destroy()
    else:
        Will()


# 点开同意,又叉掉
def closeawill():
    messagebox.showinfo(title="你咋这么犹豫", message="点了同意就是同意啦")


# 展示点击愿意后执行的命令
def Will():
    global i
    # 定义一个单独的对话框
    will = Toplevel(windon)
    # 设置大小,位置
    will.geometry("350x150+610+260")
    will.title("太好了")
    label1 = Label(will, text=say1[i], font=("华文行楷", 20))
    label1.grid()
    # 标签二
    label2 = Label(will, text=say[i], font=("华文行楷", 25))
    label2.grid(row=1, column=0)

    entry = Entry(will, font=("楷体", 15))
    entry.grid(row=2)

    btn = Button(will, text="好!", width=10, height=2, command=closeallwindon)
    btn.grid(row=3)
    will.protocol("WM_DELETE_WINDOW", closeawill)


def Unwill():
    unwill = Toplevel(windon)
    unwill.geometry("320x80+610+260")
    unwill.title("提示")
    label1 = Label(unwill, text="你点错了吧,再给你一个机会", font=("楷体", 18), fg="#596032")
    label1.pack()
    btn = Button(unwill, text="好的", width=10, height=2, command=unwill.destroy)
    btn.pack()
    unwill.protocol("WM_DELETE_WINDOW", closeUnwill)


def closeUnwill():
    messagebox.showinfo(title="警告", message="不愿意,你就关不掉")
    return


# 生成窗口
windon = tkinter.Tk()
# 标题
windon.title("来自你家老黄的请求噢")
# 设置窗口弹出的大小,位置
windon.geometry("360x425+450+200")
# 当窗口被关闭时
windon.protocol("WM_DELETE_WINDOW", closeWindon)
# 生成一个label标签放文字
label1 = tkinter.Label(windon, text="宝子跟我过日子吧", font=("华文行楷", 16), fg="red")
# 将其封装进去
label1.grid()
label2 = tkinter.Label(windon, text="嫁给我吧!", font=("华文楷体", 30), fg="blue")
# 设置字体所在的行号,并将其位置置于右边
label2.grid(row=1, column=1)

# 加载图片
picture = PhotoImage(file=r"D:\ui\play_code\image\miss_gril.gif")
# 用label标签放图片
imageLable = Label(windon, image=picture)
imageLable.grid(row=2, columnspan=2)

# 创建按钮,command跳转到函数
bnt1 = Button(windon, text="好呀", width=15, height=2, bg="pink", command=Will)
# 放置按钮
bnt1.grid(row=3, column=0, sticky=W)
# 创建第二个按钮
bnt2 = Button(windon, text="滚", width=15, height=2, bg="pink", command=Unwill)
# 放置第二个按钮
bnt2.grid(row=3, column=1, sticky=E)

# 进入消息循环
windon.mainloop()